package cn.wolfcode.trip.base.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@Getter
@Setter
public class Travel {


    //游记状态
    public static final int STATE_REJECT = -1; //拒绝状态
    public static final int STATE_NORMAL = 0;  //草稿状态
    public static final int STATE_WAITING = 1; //待审核状态
    public static final int STATE_RELEASE = 2; //发布状态(审核通过)

    private Long id;
    //游记标题
    private String title;
    //游记时间
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date travelTime;
    //人均消费
    private String perExpends;
    //旅游天数
    private Integer days;
    //跟谁旅游
    private Integer person;
    //作者
    private User author;
    //创建时间
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date createTime;
    //发布时间
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date releaseTime;
    //是否公开: true 表示公开,false表示私有
    private Boolean isPublic;
    //旅游地区
    private Region place;
    //封面
    private String coverUrl;
    //最后更新时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastUpdateTime;
    //状态
    private Integer state;

    //游记与内容的一对一关系
    private TravelContent travelContent;

    //回显对应状态的方法
    public String getStateDisplay() {
        if (state == STATE_NORMAL) {
            return "草稿状态";
        } else if (state == STATE_WAITING) {
            return "待审核状态";
        } else if (state == STATE_RELEASE) {
            return "已发布";
        } else if (state == STATE_REJECT) {
            return "拒绝";
        }
        return "";
    }
}